package com.cf.r1042_ak;

import java.io.*;

public class b {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(System.out);
        in.nextToken();
        int t = (int) in.nval;
        while (t-- > 0) {
            in.nextToken(); int n = (int) in.nval;
            StringBuilder ans = new StringBuilder();
            if ((n & 1) == 0) {
                for (int i = 0; i < n; i++) {
                    if (i == n - 1) {
                        ans.append('2');
                    } else if (i % 2 == 0) {
                        ans.append("-1" + " ");
                    } else {
                        ans.append("3" + " ");
                    }
                }
            } else {
                for (int i = 0; i < n; i++) {
                    if (i % 2 == 0) {
                        ans.append("-1" + " ");
                    } else {
                        ans.append("3" + " ");
                    }
                }
            }
            out.println(ans);
        }
        out.flush();
        out.close();
        br.close();
    }
}